# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-pyasn
pkgname=('python2-pyasn' 'python-pyasn')
_pkgname=pyasn
pkgver=1.6.2
_pyver=3.13
pkgrel=4
pkgdesc='Offline IP address to Autonomous System Number lookup module.'
arch=('x86_64' 'aarch64')
url='https://pypi.org/project/pyasn/#files'
license=('MIT')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('432d1bca71f32d6d09101d6180e512285841d1201d50e9833ed211b3d2b1d52923d9f3cff8b8763927dcc75cf44ba965d121b62ac78b9b620c40e7eb6e21c433')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-pyasn() {
  depends=('python2' 'python2-ordereddict')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --prefix=/usr --root="$pkgdir" -O1 --skip-build

  for i in "$pkgdir/usr/bin/"*; do
    mv $i "${i}2"
  done

  chmod 644 \
    "$pkgdir/usr/lib/python2.7/site-packages/pyasn-1.6.2-py2.7.egg-info/"*
}

package_python-pyasn() {
  depends=('python')

  cd "$_pkgname-$pkgver"

  python setup.py install --prefix=/usr --root="$pkgdir" -O1 --skip-build

  chmod 644 \
    "$pkgdir/usr/lib/python$_pyver/site-packages/pyasn-1.6.2-py$_pyver.egg-info/"*
}

